#!/usr/bin/env bash

if [[ "Darwin" = $(uname) ]]; then
  if [[ ! -e /etc/nginx  ]]; then sudo ln -s /usr/local/etc/nginx /etc/; fi;

  sudo chown -R ${USER} /srv/docker;
  mkdir -p /srv/docker/{{ project }}/{web,db,cache,esd};
else
  sudo mkdir -p /srv/docker/{{ project }}/{web,db,cache,esd};
fi

if [[ ! -e /srv/http ]]; then
  if [[ "Linux" = $(uname) ]]; then
    sudo ln -s /usr/share/nginx/html /srv/http
  else
    sudo ln -s /usr/local/var/www /srv/http
  fi
fi

sudo mkdir -p /etc/nginx/{conf.d,default.d}
sudo mkdir -p /etc/nginx/default.d/{{ project }}
sudo mkdir -p /srv/http/{{ project }}/uploaded/oss
sudo mkdir -p /srv/http/{{ project }}-web

# [Neo] .TODO
sudo ln -sf /srv/http/{{ project }}/uploaded /srv/docker/{{ project }}/web

docker-compose up -d
rm /tmp/todo.sh

